package lzzsrj.union.message.common.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UnionMessageAutoConfig implements BeanDefinitionRegistryPostProcessor {

    // 指定需要扫描的路径
    private static final String[] SCAN_PACKAGES = {"lzzsrj.union.message"};

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {

        // 使用扫描类，将扫描到的BeanDefinition加入到BeanDefinitionRegistry里面
        ClassPathBeanDefinitionScanner pathScanner = new ClassPathBeanDefinitionScanner(registry);
        // 扫描刚刚指定的包路径
        pathScanner.scan(SCAN_PACKAGES);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    }
}
